/**
 * @see https://umijs.org/zh-CN/plugins/plugin-access
 * */
export default function access(initialState: { currentUser?: API.CommitUserDTO } | undefined) {
  const { currentUser } = initialState ?? {};
  return {
    canAdmin: currentUser && currentUser.role === 0,
    canPlan: currentUser && (currentUser.role === 1 || currentUser.role === 0),
    canQuality: currentUser && (currentUser.role === 2 || currentUser.role === 0),
    canQMS: currentUser && (currentUser.role === 3),
  };
}
